// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
// jsdoc语法提示教程：https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129

const _db = uniCloud.database();
const db = uniCloud.databaseForJQL()
const dbCmd = db.command
module.exports = {
	_before: function () { // 通用预处理器

	},
	/**
	 * method1方法描述
	 * @param {string} param1 参数1描述
	 * @returns {object} 返回值描述
	 */
	getRankByDay: async function(param)  {
		const day = new Date();
		let today = ""+day.getFullYear() + (day.getMonth()+1) + day.getDate();
		const userInfo = await db.collection("open_user").where({
			todayscoredate: today,
			todayscore:dbCmd.gt(-2000)
		}).field('_id,avatar,nickname,updateuserdate,todayscore as userscore').limit(100).orderBy('userscore',
			'desc').get();
		return userInfo;
	},
	
	/**
	 * method1方法描述
	 * @param {string} param1 参数1描述
	 * @returns {object} 返回值描述
	 */
	getRankByTotal: async function(param)  {
		const userInfo = await db.collection("open_user").where({
			score:dbCmd.gt(60000)
		}).field('_id,avatar,nickname,updateuserdate,score as userscore').limit(100).orderBy('userscore',
			'desc').get();
		return userInfo;
	},
	
	
}
